import { defineConfig } from 'vitepress'
import { search } from './zh'

export const shared = defineConfig({
  title: 'IYUU文档',

  lastUpdated: true,
  cleanUrls: true,
  metaChunk: true,

  markdown: {
    math: true,
    image: {
      // 默认禁用图片懒加载
      lazyLoading: true
    },
    codeTransformers: [
      // We use `[!!code` in demo to prevent transformation, here we revert it back.
      {
        postprocess(code) {
          return code.replace(/\[\!\!code/g, '[!code')
        }
      }
    ],
  },

  sitemap: {
    hostname: 'https://doc.iyuu.cn',
    transformItems(items) {
      return items.filter((item) => !item.url.includes('migration'))
    }
  },

  /* prettier-ignore */
  head: [
    ['link', { rel: 'icon', type: 'image/png', href: '/logo_257.png' }],
    ['meta', { name: 'theme-color', content: '#5f67ee' }],
    ['meta', { property: 'og:type', content: 'website' }],
    ['meta', { property: 'og:locale', content: 'zh' }],
    ['meta', { property: 'og:title', content: 'IYUU文档 | 基于种子特征码的交叉索引工具' }],
    ['meta', { property: 'og:site_name', content: 'IYUU文档' }],
    ['meta', { property: 'og:image', content: '/logo_257.png' }],
    ['meta', { property: 'og:url', content: 'https://doc.iyuu.cn/' }],
    ['link', { rel: 'stylesheet', href: '/layui/css/layui.css?v=2.9.8' }],
    ['script', { src: '/layui/layui.js?v=2.9.8' }],
    ['script', { src: '/index.js?v=20241224215800' }],
    ['script', {}, `
      window._hmt = window._hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?37f060bd1a8957d2cd512f9c33f18bc0";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();`
    ],
  ],

  themeConfig: {
    logo: { src: '/logo_257.png', width: 24, height: 24 },

    socialLinks: [
      { icon: 'github', link: 'https://github.com/ledccn/iyuuplus-dev' }
    ],

    search: {
      provider: 'local',
      options: {
        locales: { ...search }
      }
    }
  }
})
